package com.zx.notification.common.enums;

import lombok.Getter;

/**
 * <p>
 * description: 目标类型枚举定义 <br>
 * create: 2025-10-15 16:55
 * </p>
 *
 * @author zhou  xun
 */
@Getter
public enum DestinationTypeEnum {
    QUEUE("QUEUE", "队列"),
    TOPIC("TOPIC", "主题");

    private final String code;
    private final String desc;

    DestinationTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据编码获取枚举值
     *
     * @param code 编码
     * @return 枚举值
     */
    public static DestinationTypeEnum getEnumByCode(String code) {
        for (DestinationTypeEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 根据描述获取枚举值
     *
     * @param desc 描述
     * @return 枚举值
     */
    public static DestinationTypeEnum getEnumByDesc(String desc) {
        for (DestinationTypeEnum value : values()) {
            if (value.desc.equals(desc)) {
                return value;
            }
        }
        return null;
    }
}